home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F31760_testBuildListWhileIntervals2.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  4.4 KB  |  123 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  3. xmlns:pGenerator="pGenerator"
  4. xmlns:pController="pController"
  5. xmlns:IntervalParams="IntervalParams"
  6. xmlns:IntegralFunction="IntegralFunction"
  7. exclude-result-prefixes="xsl msxsl pGenerator pController IntervalParams IntegralFunction"
  8. >
  9.   <!-- <xsl:import href="buildListWhile.xsl"/> -->
  10.   <xsl:import href="buildListWhileMap.xsl"/> 
  11.   
  12.    <!-- to be applied on any xml source -->
  13.    
  14.   <xsl:output indent="yes" omit-xml-declaration="yes"/>
  15.   
  16.   <pGenerator:pGenerator/>
  17.   <pController:pController/>
  18.  
  19.   <IntervalParams:IntervalParams>
  20.     <Interval>
  21.         <el>0</el>
  22.         <el>1</el>
  23.     </Interval>
  24.     <IntegralFunction:IntegralFunction/>
  25.   </IntervalParams:IntervalParams>
  26.   
  27.   <xsl:variable name="vMyGenerator" select="document('')/*/pGenerator:*[1]"/>
  28.   <xsl:variable name="vMyController" select="document('')/*/pController:*[1]"/>
  29.   <xsl:variable name="vIntervalParams" select="document('')/*/IntervalParams:*[1]"/>
  30.  
  31.   <xsl:template match="/">
  32.     <xsl:variable name="vrtfResultIntervalList">
  33.       <xsl:call-template name="buildListWhileMap">
  34.         <xsl:with-param name="pGenerator" select="$vMyGenerator"/>
  35.         <xsl:with-param name="pController" select="$vMyController"/>
  36.         <xsl:with-param name="pParam0" select="$vIntervalParams"/>
  37.         <xsl:with-param name="pContollerParam" select="256"/>
  38.       </xsl:call-template>
  39.     </xsl:variable>
  40.     
  41.     <xsl:variable name="vResultIntervalList"
  42.        select="msxsl:node-set($vrtfResultIntervalList)/*[last()]/*"/>
  43.        
  44.     <xsl:for-each select="$vResultIntervalList">
  45.      <xsl:copy-of select="."/>
  46.     </xsl:for-each>
  47.     
  48.   </xsl:template>
  49.  
  50.   <xsl:template name="listGenerator" match="*[namespace-uri()='pGenerator']">
  51.      <xsl:param name="pList" select="/.."/>
  52.      <xsl:param name="pParams"/>
  53.  
  54.      <xsl:variable name="pA0" select="string($pParams/*[1]/*[1])"/>
  55.      <xsl:variable name="pB0" select="string($pParams/*[1]/*[2])"/>
  56.      <xsl:variable name="pFun" select="$pParams/*[2]"/>
  57.      
  58.      <xsl:choose>
  59.        <xsl:when test="not($pList)">
  60.          <xsl:variable name="vFa">
  61.            <xsl:apply-templates select="$pFun">
  62.              <xsl:with-param name="pX" select="$pA0"/>
  63.            </xsl:apply-templates>
  64.          </xsl:variable>
  65.        
  66.          <xsl:variable name="vFb">
  67.            <xsl:apply-templates select="$pFun">
  68.              <xsl:with-param name="pX" select="$pB0"/>
  69.            </xsl:apply-templates>
  70.          </xsl:variable>
  71.          
  72.          <e><xsl:value-of select="$pB0 - $pA0"/></e>
  73.          <e><xsl:value-of select="$vFa"/></e>
  74.          <e><xsl:value-of select="$vFb"/></e>
  75.        </xsl:when>
  76.        <xsl:otherwise>
  77.           <xsl:variable name="vprevH" select="$pList[last()]/*[1]"/>
  78.           <xsl:variable name="vH" select="$vprevH div 2"/>
  79.           <e><xsl:value-of select="$vH"/></e>
  80.           <xsl:for-each select="$pList[last()]/*[position() > 1 
  81.                                              and position() != last()]">
  82.            <xsl:variable name="vA" select="$pA0 + (position() - 1) * $vprevH"/>
  83.            
  84.            <xsl:variable name="vMid" select="$vA + $vH"/>
  85.            
  86.            <xsl:variable name="vF_mid">
  87.              <xsl:apply-templates select="$pFun">
  88.                <xsl:with-param name="pX" select="$vMid"/>
  89.              </xsl:apply-templates>
  90.            </xsl:variable>
  91.            
  92.            
  93.            
  94.            <xsl:copy-of select="."/>
  95.            <e><xsl:value-of select="$vF_mid"/></e>
  96.          </xsl:for-each>
  97.          <xsl:copy-of select="$pList[last()]/*[last()]"/>
  98.        </xsl:otherwise>
  99.      </xsl:choose>
  100.      
  101.   </xsl:template>
  102. <!--   
  103.   <xsl:template name="listController" match="*[namespace-uri()='pController']">
  104.      <xsl:param name="pList" select="/.."/>
  105.      <xsl:param name="pParams"/>
  106.  
  107.      <xsl:if test="count($pList[last()]/*) <= $pParams">1</xsl:if>
  108.   </xsl:template>
  109. -->  
  110.   <xsl:template name="listController" match="*[namespace-uri()='pController']">
  111.      <xsl:param name="pList" select="/.."/>
  112.      <xsl:param name="pParams"/>
  113.  
  114.      <xsl:if test="count($pList[last()]/*) <= $pParams">1</xsl:if>
  115.   </xsl:template>
  116.   
  117.   <xsl:template name="myIntegralFn" match="*[namespace-uri()='IntegralFunction']">
  118.     <xsl:param name="pX"/>
  119.     
  120.     <xsl:value-of select="$pX"/>
  121.   </xsl:template>
  122.      
  123. </xsl:stylesheet>